cmake_minimum_required(VERSION 3.10)

set(target "fxcc_test_e2d_csharp_render")
project(${target})

find_program(MCS_EXECUTABLE mcs REQUIRED)

file(GLOB_RECURSE CS_SOURCES "${CMAKE_CURRENT_SOURCE_DIR}/*.cs")
set(OUTPUT_DLL "${CMAKE_CURRENT_BINARY_DIR}/${target}.dll")

source_group("CSharp Files" FILES ${CS_SOURCES})

add_library(${target}_dummy STATIC EXCLUDE_FROM_ALL dummy.cpp ${CS_SOURCES})
set_target_properties(${target}_dummy PROPERTIES
    FOLDER "CSharp"
    VS_PROJECT_LABEL "Mono C# Sources"
)

add_custom_command(
    OUTPUT ${OUTPUT_DLL}
    COMMAND ${MCS_EXECUTABLE} -target:library -out:${OUTPUT_DLL} ${CS_SOURCES}
    DEPENDS ${CS_SOURCES}
    COMMENT "Compiling all .cs files into ${OUTPUT_DLL}"
)

add_custom_target(${target} ALL DEPENDS ${OUTPUT_DLL})
set_target_properties(${target} PROPERTIES
    FOLDER "CSharp"
    VS_PROJECT_LABEL "Mono C# DLL Build"
)
